﻿using RulesEngine;

namespace NUnitTest.VipRules.Validation.Rules
{
    public class VipLevelRule : CompositeRule<INewVipCandidate>, INewVipRule
    {
        public int Index { get; set; }
        public short MinCareerLevel { get; set; }

        public short MaxCareerLevel { get; set; }

        public int ForwardOffsetMonth { get; set; }
        public bool IsPass { get; set; }
        public short CareerLevel { get; set; }

        public override bool Execute(INewVipCandidate candidate)
        {
            var result = CheckLevelCode(candidate.UserID, candidate.EffectiveDate.AddMonths(Index));
            return this.SetValidateResult(result, candidate);
        }

        private bool CheckLevelCode(long contactID, DateTime effectiveDate)
        {
            short val = 0;//CareerLevelProcesses.GetCareerLevel(contactID, effectiveDate);
            CareerLevel = val;
            if (val > MinCareerLevel && val < MaxCareerLevel)
                return true;
            return false;
        }
    }
}